<template>
  <view class="detail-wrap">
    <back class="back" :back-title="backTitle"></back>
    <view class="container">
      <swiper-container v-if="list.length" :list="list" @update-list="handleUpdate"></swiper-container>
    </view>
  </view>
</template>

<script>
import swiperContainer from '../../components/swiperContainer'
import {onlinehomeworkDetail} from '../../../../api/homework'
export default {
  name: 'detail',
  components: {
    swiperContainer
  },
  data() {
    return {
      backTitle: '在线作业',
      list: []
    }
  },
  onLoad() {
    this.initList()
  },
  methods:{
    async initList() {
			uni.showLoading({
				title: '加载中'
			})
      const res = await onlinehomeworkDetail()
			uni.hideLoading()
      this.list = res.list.map((item) => {
				item.isCheck = false
				item.subCurrentIndex  = -1
				return item
			})
    },
		handleUpdate(options) {
			console.log('出发')
			const {index, subIndex} = options
			this.$set(this.list[index], 'subCurrentIndex', subIndex)
			// console.log(...this.list)
		}
  }
}

</script>
<style lang='scss' scoped>
.detail-wrap{
  width: 100%;
  min-height:100vh;
  .back {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
  }
  .container {
    width: 100%;
    height: 100%;
    padding: 160upx 0 0;
    box-sizing: border-box;
  }
}
</style>